<template>
	<view class="container">
		<view class="prompt">为防止上传非法内容，将进行人工审核后才可使用</view>
 		<view class="hader">
			<view class="hader_tit">
				<image class="tit_icon" src="https://dysx-h5.shjiuliwl.com/Eblock/images/教程.png"></image>
				<view class="tittext">{{cardvalue.exp_last_time}} 到期</view>
				<view class="titright">卡片已到期，请激活</view>
			</view>
			<Card :Listitem="cardvalue" @tap="lookimg(cardvalue.card_code)"></Card>
		</view>
		<!-- 下方的卡片 -->
		<view class="copycard">	
			<view class="copycard_tit">
				<image class="img" src="https://dysx-h5.shjiuliwl.com/Eblock/images/教程.png"></image>
				<view class="cardtext">请复制卡片审核码，提交客服审核</view>
			</view>	
			<view class="value">{{cardvalue.card_code}}</view>
			<view class="buttom" @tap="ActivateCard">激活卡片</view>
			<!-- <view class="buttomtwo">查询进度</view> -->
		</view>
	</view>
</template>

<script>
import { onGotApiData , getService } from '../../utils/api.js';
import Card from '../../components/lists/card.vue'
export default {
	data() {
		return {
			cardvalue: {}, // 获取到的值
			card_code:'',
			userId:'',
			servicevalue:{},
		}
	},
	components: {
		'Card': Card
	},
	onLoad(option){
		this.userId = uni.getStorageSync('dysx_userId')||''	
		this.card_code = option.card_code
		// 获取卡片信息
		this.getcard()
		// 获取客服链接
		this.getservice()
	},
	methods: {
		// 获取卡片基础信息
		getcard () {
			const params = {
				code: this.card_code,
			}
			onGotApiData('/wxxcx_api/card/v1/get','GET',params,this.card_value)
		},
		// 获取基础信息结果
		card_value (result) {
			if(result.code =200){
				console.log('卡片信息',result)
				this.cardvalue  = result.data
				
			}
		},
		// 获取客服
		getservice(){
			let params = {
			}
			onGotApiData('/wxxcx_api/kf/get','GET',params,this.service_value)
		},
		// 客服信息结果
		service_value(result){
			console.log('result',result)
			if(result.code == 200){
				this.servicevalue = result.data
			}
		},
		// 点击联系客服
		service() {
			const that = this
			// window.location.href = 'https://work.weixin.qq.com/kfid/kfc57df3bacfa1fd3f9'
			wx.openCustomerServiceChat({
				extInfo: {url: `${that.servicevalue.kf_link}`},
				corpId: that.servicevalue.corpId,
				success(res) {
					console.log("我是客服",res)
				},
				fail(res){ 
					console.log("我是失败客服",res)
				}
			})
		},
		// 激活卡片
		ActivateCard(){
			let params = {
				card_code:this.card_code,
				user_id	:this.userId,
			}
			onGotApiData('/wxxcx_api/card/v1/activate','POST',params,this.ActivateCard_value)
		},
		ActivateCard_value(result){
			if(result.code ==200){
				uni.showToast({
					title: '卡片激活成功',
					icon: 'none',
					//显示持续时间为 2秒
					duration: 2000
				})
			}else if(result.code == 401){
				uni.showToast({
					title: '未开通会员 跳转到会员页面',
					icon: 'none',
					//显示持续时间为 2秒
					duration: 2000
				})
				setTimeout(()=>{
					uni.navigateTo({
						url: '/pages/payvip/payvip'
					});
				},2000)
			}else{
				uni.showToast({
					title: result.message,
					icon: 'none',
					//显示持续时间为 2秒
					duration: 2000
				})
			}
		},
		// 跳转到查询二维码页面
		lookimg(code){
			// console.log('xxx')
			uni.navigateTo({
				url: '/pages/qrcode/qrcode?card_code=' + code
			});
		},
	}
}
</script>

<style scoped lang="scss">
	.container {
		width: 100vw;
		max-width: 750rpx;
		min-height: 100vh;
		margin: 0 auto;
		padding: 10rpx 0;
		overflow: hidden;
		font-family: '思源黑体';
		background: linear-gradient(180deg, rgba(115, 149, 250, 1) 0%, rgba(68, 114, 252, 1) 75.7%, rgba(115, 149, 250, 0) 100%)no-repeat;
		background-size:100% 30%;
		.prompt{
			width: 750rpx;
			height: 50rpx;
			font-size: 28rpx;
			line-height: 50rpx;
			margin: 0 auto;
			margin-top: 30rpx;
			margin-bottom: 20rpx;
			text-align: center;
			color: rgba(255, 255, 255, 1);
		}																																																
		.hader{
			width: 730rpx;
			// height: 210rpx;
			border-radius: 10rpx;
			margin: 0 auto;
			margin-top: 10rpx;
			padding-bottom: 10rpx;
			background: rgba(255, 255, 255, 1);
			box-shadow: 0px 2px 4px  rgba(0, 0, 0, 0.25);
			.hader_tit{
				width: 730rpx;
				height: 80rpx;
				display: flex;
				justify-content: space-between;
				// border: 1px solid black;
				.tit_icon{
					width: 48rpx;
					height: 48rpx;
					// border: 1px solid black;
					margin: 15rpx;
				}
				.tittext{
					width: 420rpx;
					height: 80rpx;
					// border: 1px solid black;
					font-size: 28rpx;
					font-weight: 700;
					line-height: 74rpx;
					color: rgba(56, 56, 56, 1);
				}
				.titright{
					width: 260rpx;
					height:50rpx;
					opacity: 1;
					border-radius: 0px 4px 0px 6px;
					background: linear-gradient(90deg, rgba(255, 124, 71, 1) 0%, rgba(255, 74, 3, 1) 100%);				
					font-size: 26rpx;
					line-height: 50rpx;
					color: rgba(255, 255, 255, 1);
					text-align: center;
				}
			}

		}
		.copycard{
			width: 730rpx;
			// height: 210rpx;
			border-radius: 10rpx;
			margin: 0 auto;
			margin-top: 20rpx;
			padding: 16rpx 0 40rpx 0;
			background: rgba(255, 255, 255, 1);
			box-shadow: 0px 2px 4px  rgba(0, 0, 0, 0.25);
			.copycard_tit{
				width: 700rpx;
				height: 70rpx;
				// border: 1px solid black;
				margin: 0 auto;
				display: flex;
				.img{
					width: 48rpx;
					height: 48rpx;
					margin: 11rpx 0;
				}
				.cardtext{
					width: 512rpx;
					height: 70rpx;
					font-size: 28rpx;
					font-weight: 700;
					line-height: 70rpx;
					color: rgba(56, 56, 56, 1);
					margin-left: 10rpx;
				}
			}
			.value{
				width: 500rpx;
				height: 200rpx;
				margin: 0 auto;
				margin-top: 20rpx;
				font-size: 48px;
				font-weight: 700;
				line-height: 200rpx;
				color: rgba(56, 56, 56, 1);
				text-align: center;
				// border: 1px solid black;
			}
			.buttom{
				width: 500rpx;
				height: 90rpx;
				border-radius: 30px;
				background: rgba(91, 121, 252, 100);
				box-shadow: 0px 8px 5px  rgba(0, 0, 0, 0.25);
				margin: 0 auto;
				margin-top: 20rpx;
				font-size: 32rpx;
				line-height: 90rpx;
				color: rgba(255, 255, 255, 1);
				text-align: center;
			}
			.buttomtwo{
				width: 500rpx;
				height: 90rpx;
				border-radius: 30px;
				box-shadow: 0px 8px 5px  rgba(0, 0, 0, 0.25);
				margin: 0 auto;
				margin-top: 20rpx;
				font-size: 32rpx;
				line-height: 90rpx;
				color: rgba(255, 255, 255, 1);
				text-align: center;
				background: linear-gradient(90deg, rgba(255, 124, 71, 1) 0%, rgba(255, 74, 3, 1) 100%);
			}
		}	
	}
</style>
